updating oE db_connect

Managing Databases

db_connect

include eds.e 
namespace eds 
public function db_connect(sequence dbalias, sequence path = "", sequence dboptions = {}) 

defines a symbolic name for a database and its default attributes.

Parameters:
  1. dbalias : a sequence. This is the symbolic name that the database can be referred to by.
  2. path : a sequence, the path to the file that will contain the database.
  3. dboptions: a sequence. Contains the set of attributes for the database. The default is {} meaning it will use the various EDS default values.
Returns:

An integer, status code, either DB_OK if creation successful or anything else on an error.

Comments:
  • This does not create or open a database. It only associates a symbolic name with a database path. This name can then be used in the calls to db_create, db_open, and db_select instead of the physical database name.
  • If the file in the path does not have an extention, ".edb" will be added automatically.
  • The dboptions can contain any of the options detailed below. These can be given as a single string of the form "option=value, option=value, ..." or as as sequence containing option-value pairs, { {option,value}, {option,value}, ... } Note: The options can be in any order.
  • The options are:
    • LOCK_METHOD : an integer specifying which type of access can be granted to the database. This must be one of DB_LOCK_NO, DB_LOCK_EXCLUSIVE, DB_LOCK_SHARDED or DB_LOCK_READ_ONLY.
    • INIT_TABLES : an integer giving the initial number of tables to reserve space for. The default is 5 and the minimum is 1.
    • INIT_FREE : an integer giving the initial amount of free space pointers to reserve space for. The default is 5 and the minimum is 0.
  • If a symbolic name has already been defined for a database, you can get it's full path and options by calling this function with dboptions set to CONNECTION. The returned value is a sequence of two elements. The first is the full path name and the second is a list of the option values. These options are indexed by [CONNECT_LOCK], [CONNECT_TABLES], and [CONNECT_FREE].
  • If a symbolic name has already been defined for a database, you remove the symbolic name by calling this function with dboptions set to DISCONNECT.
Example 1:
db_connect("myDB", "/usr/data/myapp/customer.edb", {{LOCK_METHOD,DB_LOCK_NO}, 
                                                            {INIT_TABLES,1}}) 
db_open("myDB") 
Example 2:
db_connect("myDB", "/usr/data/myapp/customer.edb",  
                          sprintf("init_tables=1,lock_method=%d",DB_LOCK_NO)) 
db_open("myDB") 
Example 3:
db_connect("myDB", "/usr/data/myapp/customer.edb",  
                          sprintf("init_tables=1,lock_method=%d",DB_LOCK_NO)) 
db_connect("myDB",,CONNECTION) --> {"/usr/data/myapp/customer.edb", {0,1,1}} 
db_connect("myDB",,DISCONNECT) -- The name 'myDB' is removed from EDS. 
See Also:

db_create, db_open, db_select

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu